<template>
  <view class="mine-container">
    <!-- 顶部背景 -->
    <view class="header-bg">
      <image
        class="bg-image"
        src="@/static/qietu/上面底部@2x.png"
        mode="widthFix"
      />
    </view>
    
    <!-- 用户信息 -->
    <view class="user-info">
      <view class="avatar-box">
        <image class="avatar" src="@/static/qietu/圆形 6.png" mode="aspectFill"></image>
      </view>
      <view class="user-detail">
        <text class="username">用户昵称</text>
        <view class="user-level">
          <text class="level-tag">会员</text>
          <text class="points">积分: 366</text>
        </view>
      </view>
      <view class="vip-card">
        <text>会员卡</text>
        <text class="icon-right">></text>
      </view>
    </view>
    
    <!-- 我的订单 -->
    <view class="order-card card-shadow">
      <view class="card-header">
        <text class="title">我的订单</text>
        <view class="more" @click="goToOrders">
          <text>查看全部</text>
          <text class="icon-right">></text>
        </view>
      </view>
      <view class="order-types">
        <view class="order-type-item" @click="goToOrdersByStatus('pending')">
          <view class="icon-circle">
            <text class="icon-payment">￥</text>
          </view>
          <text>待付款</text>
        </view>
        <view class="order-type-item" @click="goToOrdersByStatus('processing')">
          <view class="icon-circle">
            <text class="icon-processing">♨</text>
          </view>
          <text>制作中</text>
        </view>
        <view class="order-type-item" @click="goToOrdersByStatus('completed')">
          <view class="icon-circle">
            <text class="icon-completed">✓</text>
          </view>
          <text>已完成</text>
        </view>
        <view class="order-type-item" @click="goToOrdersByStatus('cancelled')">
          <view class="icon-circle">
            <text class="icon-cancelled">✕</text>
          </view>
          <text>已取消</text>
        </view>
      </view>
    </view>
    
    <!-- 我的资产 -->
    <view class="assets-card card-shadow">
      <view class="card-header">
        <text class="title">我的资产</text>
      </view>
      <view class="assets-list">
        <view class="asset-item" @click="goToAsset('wallet')">
          <view class="asset-value">0</view>
          <view class="asset-name">钱包余额</view>
        </view>
        <view class="asset-item" @click="goToAsset('coupon')">
          <view class="asset-value">2</view>
          <view class="asset-name">优惠券</view>
        </view>
        <view class="asset-item" @click="goToAsset('points')">
          <view class="asset-value">366</view>
          <view class="asset-name">积分</view>
        </view>
      </view>
    </view>
    
    <!-- 常用功能 -->
    <view class="functions-card card-shadow">
      <view class="card-header">
        <text class="title">常用功能</text>
      </view>
      <view class="function-list">
        <view class="function-item" @click="goToFunction('address')">
          <view class="function-icon">📍</view>
          <text>地址管理</text>
        </view>
        <view class="function-item" @click="goToFunction('favorite')">
          <view class="function-icon">❤️</view>
          <text>我的收藏</text>
        </view>
        <view class="function-item" @click="goToFunction('customer')">
          <view class="function-icon">📞</view>
          <text>联系客服</text>
        </view>
        <view class="function-item" @click="goToFunction('feedback')">
          <view class="function-icon">💬</view>
          <text>意见反馈</text>
        </view>
        <view class="function-item" @click="goToFunction('about')">
          <view class="function-icon">ℹ️</view>
          <text>关于我们</text>
        </view>
        <view class="function-item" @click="goToFunction('settings')">
          <view class="function-icon">⚙️</view>
          <text>设置</text>
        </view>
      </view>
    </view>
    
    <!-- 底部 -->
    <view class="footer">
      <text class="app-version">微餐饮 v1.0.0</text>
    </view>
    
    <!-- 底部导航栏 -->
    <tab-bar />
  </view>
</template>

<script setup>
import { ref } from 'vue';
import * as uniApi from '@/common/utils/uni-api.js';
import tabBar from "@/components/TabBar/index.vue";

// 跳转到我的订单页面
const goToOrders = () => {
  uniApi.showToast('功能开发中');
};

// 按状态查看订单
const goToOrdersByStatus = (status) => {
  uniApi.showToast(`${status}订单功能开发中`);
};

// 查看资产
const goToAsset = (type) => {
  uniApi.showToast(`${type}功能开发中`);
};

// 常用功能
const goToFunction = (type) => {
  uniApi.showToast(`${type}功能开发中`);
};
</script>

<style lang="scss" scoped>
.mine-container {
  min-height: 100vh;
  background-color: #f8f8f8;
}

.header-bg {
  width: 100%;
  position: relative;
  
  .bg-image {
    width: 100%;
  }
}

.user-info {
  position: relative;
  margin: -150rpx 30rpx 30rpx;
  background-color: #fff;
  border-radius: 20rpx;
  padding: 30rpx;
  display: flex;
  align-items: center;
  box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.05);
  z-index: 1;
}

.avatar-box {
  margin-right: 20rpx;
}

.avatar {
  width: 120rpx;
  height: 120rpx;
  border-radius: 50%;
  border: 4rpx solid #fff;
  box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.1);
}

.user-detail {
  flex: 1;
}

.username {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 10rpx;
}

.user-level {
  display: flex;
  align-items: center;
}

.level-tag {
  background-color: #fa436a;
  color: #fff;
  font-size: 20rpx;
  padding: 2rpx 10rpx;
  border-radius: 10rpx;
  margin-right: 10rpx;
}

.points {
  font-size: 24rpx;
  color: #666;
}

.vip-card {
  background-color: #ffe44d;
  color: #333;
  font-size: 24rpx;
  padding: 10rpx 20rpx;
  border-radius: 100rpx;
  display: flex;
  align-items: center;
}

.icon-right {
  margin-left: 6rpx;
  font-size: 24rpx;
}

.card-shadow {
  background-color: #fff;
  border-radius: 16rpx;
  margin: 0 30rpx 30rpx;
  padding: 30rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30rpx;
}

.title {
  font-size: 30rpx;
  font-weight: bold;
  color: #333;
}

.more {
  font-size: 24rpx;
  color: #999;
  display: flex;
  align-items: center;
}

.order-types {
  display: flex;
  justify-content: space-between;
}

.order-type-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 24rpx;
  color: #666;
}

.icon-circle {
  width: 80rpx;
  height: 80rpx;
  background-color: #f8f8f8;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10rpx;
  font-size: 32rpx;
}

.icon-payment {
  color: #fa436a;
}

.icon-processing {
  color: #f39c12;
}

.icon-completed {
  color: #2ecc71;
}

.icon-cancelled {
  color: #999;
}

.assets-list {
  display: flex;
  justify-content: space-between;
}

.asset-item {
  text-align: center;
  width: 33.33%;
}

.asset-value {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 10rpx;
}

.asset-name {
  font-size: 24rpx;
  color: #666;
}

.function-list {
  display: flex;
  flex-wrap: wrap;
}

.function-item {
  width: 33.33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20rpx 0;
  font-size: 24rpx;
  color: #666;
}

.function-icon {
  font-size: 48rpx;
  margin-bottom: 10rpx;
}

.footer {
  text-align: center;
  padding: 30rpx 0 120rpx;
}

.app-version {
  font-size: 24rpx;
  color: #999;
}
</style>